<?php
class CMS_Models_LangClientCategory extends Zend_Db_Table_Abstract
{
	protected $_name = "lang_client_category";
	
	public function __construct( )
   	{
   	 parent::__construct(array('table' =>$this->_name));
   	}
	
    public function getAll()
    {
      $contact = $this->fetchAll(array());
   	  return $contact;
    }
    
    public function getCategoriesByLang($lang)
    {
      $sql = "select c.*,cxi.* from client_category c
      		  inner join lang_client_category cxi
      		  on ( cxi.id_category = c.id )
      		  where cxi.lang = '$lang'";
      return TN_Db::getInstance()->fetchAll($sql);
    }
    
    public function getCategoryByKey($id, $lang)
    {
      $sql = "select c.*,cxi.* from client_category c
      		  inner join lang_client_category cxi
      		  on ( cxi.id_category = c.id )
      		  where cxi.lang = '$lang' and cxi.id_category = '$id'";
      return TN_Db::getInstance()->fetchRow($sql);
    }
    /**
     * Devuelve la categoria en todos los idiomas
     * @param unknown_type $id
     */
    public function getCategoryById($id, $lang)
    {
      	$category = $this->fetchRow("id_category = '$id' and lang = '$lang'");
      	return $category;
    }
}